﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharpHomeEngine;

namespace Insteon.Requests
{

    /// <summary>
    /// I am the base class for all insteon requests.
    /// I am the document that the controller can fill out, pass to the state engine, 
    /// and it will find its way back to the insteon interface where it will execute.
    /// Calling this.Finish() or its cousins Complete(), Succeed(), etc will cause me to go 
    /// back to the state engine where I will unblock the request and be used in events.
    /// these events will notify everyone that I completed.
    /// </summary>
    public abstract class InsteonRequest : Request4DeviceInterface
    {

        internal readonly InsteonInterface InsteonInterface;
        public InsteonRequest(Controller Controller, InsteonInterface Interface)
            : base(Controller, Interface)
        {
            this.InsteonInterface = Interface;
        }

        /// <summary>
        /// Insteon Specific requests should be smart enought to handle themselves.
        /// this will begin execution, which will probably involve creating an insteon command and placing it in the queue
        /// </summary>
        internal abstract void BeginExecute();

        /// <summary>
        /// when insteon commands are completed, this function gets called.
        /// you can either complete the request or generate more commands.
        /// so on and so forth.
        /// You can complete me by calling this.Finish, etc.
        /// </summary>
        /// <param name="Command"></param>
        internal abstract void CommandCompleted(Commands.Command Command);
    }
}
